<template>
  <div>
    <!-- 使用Header组件 -->
    <HeaderComponent 
      :isLoggedIn="userStore.isLoggedIn"
      :userInfo="userStore.userInfo"
      :showUserPanel="showUserPanel"
      @toggle-user-panel="toggleUserPanel"
      @logout="handleLogout"
    />
    
    <div class="footprints-page">
      <div class="page-header">
        <h1 class="page-title">我的足迹</h1>
        <p class="page-subtitle">记录您的学习历程和浏览记录</p>
      </div>
      
      <div class="footprints-container">
        <div class="footprints-tabs">
          <div class="tab-item active">浏览记录</div>
          <div class="tab-item">学习进度</div>
          <div class="tab-item">访问统计</div>
        </div>
        
        <div class="footprints-content">
          <div class="stats-overview">
            <div class="stat-card">
              <div class="stat-icon">👀</div>
              <div class="stat-info">
                <div class="stat-number">128</div>
                <div class="stat-label">今日浏览</div>
              </div>
            </div>
            <div class="stat-card">
              <div class="stat-icon">📚</div>
              <div class="stat-info">
                <div class="stat-number">45</div>
                <div class="stat-label">学习时长(分钟)</div>
              </div>
            </div>
            <div class="stat-card">
              <div class="stat-icon">🎯</div>
              <div class="stat-info">
                <div class="stat-number">12</div>
                <div class="stat-label">完成课程</div>
              </div>
            </div>
          </div>
          
          <div class="recent-activities">
            <h3 class="section-title">最近活动</h3>
            <div class="activity-list">
              <div class="activity-item">
                <div class="activity-time">2小时前</div>
                <div class="activity-content">
                  <span class="activity-action">浏览了</span>
                  <span class="activity-target">Vue.js 进阶教程</span>
                </div>
              </div>
              <div class="activity-item">
                <div class="activity-time">5小时前</div>
                <div class="activity-content">
                  <span class="activity-action">完成了</span>
                  <span class="activity-target">JavaScript 基础练习</span>
                </div>
              </div>
              <div class="activity-item">
                <div class="activity-time">1天前</div>
                <div class="activity-content">
                  <span class="activity-action">收藏了</span>
                  <span class="activity-target">React Hooks 最佳实践</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import HeaderComponent from '@/components/HeaderComponent.vue'
import { useUserStore } from '@/stores/user.js'

export default {
  name: 'MyFootprints',
  components: {
    HeaderComponent
  },
  setup() {
    const userStore = useUserStore();
    return {
      userStore
    }
  },
  data() {
    return {
      showUserPanel: false
    }
  },
  methods: {
    toggleUserPanel() {
      this.showUserPanel = !this.showUserPanel;
    },
    handleLogout() {
      this.userStore.logout();
      this.$router.push('/');
    }
  }
}
</script>

<style scoped>
.footprints-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background-color: #f4f5f5;
  min-height: 100vh;
}

.page-header {
  background: white;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.page-title {
  font-size: 28px;
  font-weight: bold;
  color: #1d2129;
  margin: 0 0 8px 0;
}

.page-subtitle {
  font-size: 16px;
  color: #86909c;
  margin: 0;
}

.footprints-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.footprints-tabs {
  display: flex;
  border-bottom: 1px solid #e4e6eb;
  padding: 0 24px;
}

.tab-item {
  padding: 16px 20px;
  cursor: pointer;
  color: #86909c;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-item.active {
  color: #1e80ff;
  border-bottom-color: #1e80ff;
}

.tab-item:hover {
  color: #1e80ff;
}

.footprints-content {
  padding: 24px;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: #f7f8fa;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  font-size: 32px;
}

.stat-number {
  font-size: 24px;
  font-weight: bold;
  color: #1d2129;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #86909c;
}

.section-title {
  font-size: 18px;
  font-weight: bold;
  color: #1d2129;
  margin: 0 0 16px 0;
}

.activity-list {
  space-y: 12px;
}

.activity-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-time {
  font-size: 12px;
  color: #86909c;
  width: 80px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  margin-left: 16px;
}

.activity-action {
  color: #86909c;
  margin-right: 4px;
}

.activity-target {
  color: #1e80ff;
  font-weight: 500;
}
</style>